package com.kygeng.dataupdate.function;


import com.kygeng.common.model.CompanyDetail;
import com.kygeng.common.model.document.CompanyInfoDoc;
import com.kygeng.dataupdate.mapper.CompanyInfoMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Title: CompanySearchFunction
 * @Author: kygeng
 * @Package: com.kygeng.datamonitior.function
 * @Date: 2024/9/8 10:40
 * @Description:
 */
@Service
public class CompanySearchFunction {

    @Autowired
    private CompanyInfoMapper companyInfoMapper;


    /**
     * 根据公司编号查询 公司文档对象
     *
     * @param companyCodes 公司编号
     * @return
     */
    public List<CompanyInfoDoc> getCompanyInfoDocBatch(List<String> companyCodes) {
        List<CompanyDetail> companyDetails = companyInfoMapper.selectCompanyDetail(companyCodes);
        List<CompanyInfoDoc> result = new ArrayList<>();
        for (CompanyDetail companyDetail : companyDetails) {
            result.add(changeToCompanyInfoDoc(companyDetail));
        }
        return result;
    }


    private CompanyInfoDoc changeToCompanyInfoDoc(CompanyDetail companyDetail) {
        CompanyInfoDoc result = new CompanyInfoDoc();
        BeanUtils.copyProperties(companyDetail,result);
        return result;
    }

}
